package com.bwf.map;

import java.util.*;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/24 14:49
 * @Copyright 博为峰
 */
public class HashMapDemo02 {
    public static void main(String[] args) {
        final HashMap<Student, String> hashMap = new HashMap<>();
        hashMap.put(new Student("张三", 20), "北京");
        hashMap.put(new Student("李四", 30), "上海");
        hashMap.put(new Student("王五", 50), "广州");
//        hashMap.put(new Student("王五", 50), "广州");
//        final Collection<String> values = hashMap.values();
//        m2(hashMap);
//        m1(hashMap);
        new TreeMap<>().put("","");
        new Hashtable<>();
    }

    private static void m2(HashMap<Student, String> hashMap) {
        final Set<Student> set = hashMap.keySet();
        final Iterator<Student> iterator = set.iterator();
        while (iterator.hasNext()){
            final Student key = iterator.next();
            final String value = hashMap.get(key);
        }
    }

    private static void m1(HashMap<Student, String> hashMap) {
        final Set<Map.Entry<Student, String>> set = hashMap.entrySet();
        final Iterator<Map.Entry<Student, String>> iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry<Student, String> next = iterator.next();
            System.out.println(next.getKey());
            System.out.println(next.getValue());
            System.out.println("--------------------------");
        }
    }
}
